Dear DXL experts,
Am trying to match below string to extract chapter numbers as shown below ========================================================= Regexp hasField = regexp "(([0-9]+.[0-9]+ ).|([0-9]+.[0-9]+.[0-9]+.[0-9]+)|([0-9]+.[0-9]+.[0-9]+.[0-9]+.[0-9]+) )" string s = "12.13.2.334.1 The vehicle shall initially be operated in "
if(hasField s) ========================================================= below code prints only "12.13.2.334", i want to extract 12.13.2.334.1. string "s" may contain 1.1 or 1.1.1 or 1.22.34.456.20 or 1 or etc in the beginning of the string Can you please help to find out the issue in Regexp
Thanks in Advance ukrishne
ukrishne - Wed Jan 17 23:55:40 EST 2018 |
Re: Regexp for chapter numbers matching try something like: "[0-9]+(\\.[0-9]+)*" it expects a number in front and then zero-to-infinite blocks containing of a dot-separator and another number, meaning: 1 1.1 1.12.3 1.23.456.7890.1.2.3.4 are all valid. Regexp should match the longest match by default, if it doesn't try adding a space after the "*" at the end.
(Also "." in regexp means "any non newline character", if you want an actual dot you have to escape it with backslashes) |
Re: Regexp for chapter numbers matching O.Wilkop - Thu Jan 18 04:08:41 EST 2018 try something like: "[0-9]+(\\.[0-9]+)*" it expects a number in front and then zero-to-infinite blocks containing of a dot-separator and another number, meaning: 1 1.1 1.12.3 1.23.456.7890.1.2.3.4 are all valid. Regexp should match the longest match by default, if it doesn't try adding a space after the "*" at the end.
(Also "." in regexp means "any non newline character", if you want an actual dot you have to escape it with backslashes) great help. It worked. |